﻿@model ManufacturerModel
@inject SeoSettings seoSettings
@inject IPageHeadBuilder pagebuilder
@{
    Layout = "_ColumnsTwo";
    pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
    pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var manufacturerUrl = Url.RouteUrl("Manufacturer", new { SeName = Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);
        pagebuilder.AddCanonicalUrlParts(manufacturerUrl);
    }
}

<div class="page manufacturer-page">
    <h1 class="generalTitle h2">@Model.Name</h1>
    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_top", additionalData = Model.Id })
    @*description*@
    @if (!String.IsNullOrWhiteSpace(Model.Description))
    {
        <b-card no-body class="manufacturer-description">
            @Html.Raw(Model.Description)
        </b-card>
    }
    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_before_featured_products", additionalData = Model.Id })
    @*featured products*@
    @if (Model.FeaturedProducts.Any())
    {
        <div class="page-separator"></div>
        <b-col cols="12" class="product-grid featured-product-grid px-0">
            <h2 class="h5 text-left mb-3">
                <span>@T("Products.FeaturedProducts")</span>
            </h2>
            <b-form-row>
                @foreach (var item in Model.FeaturedProducts)
                {
                    <b-col lg="4" sm="6" cols="6" class="product-container mb-2">
                        <partial name="_ProductBox" model="item" />
                    </b-col>
                }
            </b-form-row>
        </b-col>
    }
    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_after_featured_products", additionalData = Model.Id })
    @if (Model.Products.Any())
    {
        <partial name="_CatalogSelectors" model="Model.PagingFilteringContext" />
    }
    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_before_filters", additionalData = Model.Id })

    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_before_product_list", additionalData = Model.Id })
    @if (Model.Products.Any())
    {
        if (Model.PagingFilteringContext.ViewMode == "grid")
        {
            <b-col cols="12" class="product-grid px-0">
                <b-form-row>
                    @foreach (var product in Model.Products)
                    {
                        <b-col lg="4" sm="6" cols="6" class="product-container mb-2">
                            <partial name="_ProductBox" model="product" />
                        </b-col>
                    }
                </b-form-row>
                 <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />
            </b-col>
        }
        else
        {
            <div class="product-grid">
                <b-col cols="12">
                    <b-row class="row">
                        @foreach (var product in Model.Products)
                        {
                            <partial name="_ProductBoxList" model="product" />
                        }
                        <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />
                    </b-row>
                </b-col>
            </div>
        }
    }

    @*bottom description*@
    @if (!String.IsNullOrWhiteSpace(Model.BottomDescription))
    {
        <b-card no-body class="manufacturer-description">
            @Html.Raw(Model.BottomDescription)
        </b-card>
    }

    @await Component.InvokeAsync("Widget", new { widgetZone = "manufacturerdetails_bottom", additionalData = Model.Id })
</div>

@section filters
    {
    @*filtering*@
    @if (Model.PagingFilteringContext.PriceRangeFilter.Enabled)
    {
        <partial name="_FilterPriceBox" model="Model.PagingFilteringContext.PriceRangeFilter" />
    }
    @*filtering*@
    @if (Model.PagingFilteringContext.SpecificationFilter.Enabled)
    {
        <partial name="_FilterSpecsBox" model="Model.PagingFilteringContext.SpecificationFilter" />
    }
}

